package edu.mis.modules.room;

import java.util.List;

import com.jfinal.plugin.activerecord.Record;

import edu.mis.model.Room;

public class RoomService {
	
	
	/**
	 * 查询所有房间及其状态
	 * @return
	 */
	public List<Record> findAllRoomWithCondition(){
		return Room.dao.findAllRecord();
	}
	
	
	/**
	 * 添加房间
	 * @param room
	 * @return
	 */
	public boolean saveRoom(Room room){
		if(room.findRoomByRoomNumber(room.getRoomNumber())==null){
			return room.save();
		}
		else {
			return false;
		}
	}
	
	/**
	 * 修改房间
	 * @param roomNumber
	 * @return
	 */
	public boolean updateRoom(Room room){
		return room.update();
	}
	
	/**
	 * 根据ID得到房间
	 * @param roomId
	 * @return
	 */
	public Room findRoomByRoomId(int roomId) {
		return Room.dao.findById(roomId);
	}
	
	/**
	 * 查询所有房间
	 * @return
	 */
	public List<Room> findAllRoom(){
		return Room.dao.findAll();
	}
	
	/**
	 * 查询所有空房间
	 * @return
	 */
	public List<Room> findSpaceRoom(int conditionId){
		return Room.dao.findSpaceRoom(conditionId);
	}
	
	/**
	 * 删除房间
	 * @param roomId
	 * @return
	 */
	public boolean deleteRoomByRoomId(int roomId) {
		return Room.dao.deleteById(roomId);
	}
	
}
